Intersoft WebTextEditor Documentation
How-to: Add Custom Command using InitializeToolBar server-side event
See Also Send Feedback
Intersoft WebTextEditor > WebTextEditor > ToolBar > Customize toolbar programmatically from server-side > How-to: Add Custom Command using InitializeToolBar server-side event

Glossary Item Box

WebTextEditor provides a property to add a new command during InitializeToolBar server side event.

In this topic, you will learn how to enable keyboard support.

To add Custom Command during server side event

  1. Implement InitializeToolBar server side event in the WebTextEditor. Here is the snippet to add the custom command to the Standard toolbar:
    C# Copy Code
    protected void WebTextEditor1_InitializeToolBar(object sender, ISNet.WebUI.WebTextEditor.WebTextEditorToolBarArgs e)
    {  
       WebTextEditorToolBar tb = e.GetToolBarByCategory(WebTextEditorToolBarCategory.Standard);   
    
       WebTextEditorToolCommand tbCommand = tb.ToolCommands.CreateNewItem();  
       tbCommand.Name = "cmdCustomButton";  
       tbCommand.Text = "Custom Command";   
    
       tb.ToolCommands.Add(tbCommand);
    }
    

  2. Implement onToolBarClick client side event to display a message when the newly created command is clicked. Here is the snippet:
    Javascript Copy Code
    function WebTextEditor1_OnToolBarClick(controlId, command, commandSection)
    {    
       var rte = ISGetObject(controlId);     
       switch (command.Name)    
       {        
          case "cmdCustomButton":            
               alert("Custom button clicked");            
               break;    
       }
    }
    

See Also

©2013. All Rights Reserved.